=begin
 *
 * File: sif_file_reader.rb
 * S-expression Interpreter Framework (SIF).
 * Version 1.0
 *
 * Reads and interprets an s-exp source file, one expression at a time.
 * Additionally, it catches all runtime errors.
 *
 * Copyright (C) 2006-2008 by Ariel Ortiz <ariel.ortiz@itesm.mx>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
=end

def interpret(ctx)
  begin

    if ARGV.length == 1
      str = File.read(ARGV.first)
      Interpreter.eval(str, ctx) do |x|
        puts x.to_sexp if x
      end
    else
      raise InterpreterError.new('You must specify one s-exp source file')
    end

  rescue => error
    puts 'ERROR: %s!' % [error]

  end
end